﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Resources;
using System.Web;

namespace ALinq.BBS
{
    /// <summary>
    /// 系统消息。
    /// </summary>
    public static class ClientMessage
    {
        static ResourceManager resource;

        private static string GetMessage(string name)
        {
            if (resource == null)
                resource = new ResourceManager(typeof(ClientMessage));
            return resource.GetString(name);
        }

        /// <summary>
        /// 该用户不存在！
        /// </summary>
        public static string NoThisUser
        {
            get
            {
                return GetMessage("NoThisUser");
            }
        }

        /// <summary>
        /// 密码错误！
        /// </summary>
        public static string PasswordError
        {
            get
            {
                return GetMessage("PasswordError");
            }
        }

        /// <summary>
        /// 成功登录！
        /// </summary>
        public static string LoginSuccess
        {
            get
            {
                return GetMessage("LoginSuccess");
            }
        }

        /// <summary>
        /// 成功退出！
        /// </summary>
        public static string LogoutSuccess
        {
            get
            {
                return GetMessage("LogoutSuccess");
            }
        }

        /// <summary>
        /// 退出成功！
        /// </summary>
        public static string LogoutFail
        {
            get
            {
                return GetMessage("LogoutFail");
            }
        }

        /// <summary>
        /// 添加帖子成功！
        /// </summary>
        public static string AddPostSuccess
        {
            get
            {
                return GetMessage("AddPostSuccess");
            }
        }

        /// <summary>
        /// 添加帖子失败！
        /// </summary>
        public static string AddPostFail
        {
            get
            {
                return GetMessage("AddPostFail");
            }
        }

        /// <summary>
        /// 添加版块成功！
        /// </summary>
        public static string AddPostCatalgSuccess
        {
            get
            {
                return GetMessage("AddPostCatalgSuccess");
            }
        }
        #region 注册
        /// <summary>
        /// 注册成功！
        /// </summary>
        public static string RegisterSuccess
        {
            get
            {
                return GetMessage("RegisterSuccess");
            }
        }

        /// <summary>
        /// 用户名不能为空！
        /// </summary>
        public static string NameNotNull
        {
            get
            {
                return GetMessage("NameNotNull");
            }
        }

        /// <summary>
        /// 密码不能为空！
        /// </summary>
        public static string PasswordNotNull
        {
            get
            {
                return GetMessage("PasswordNotNull");
            }
        }

        /// <summary>
        /// 请确认你所输入的密码！
        /// </summary>
        public static string ConfirmPassword
        {
            get
            {
                return GetMessage("ConfirmPassword");
            }
        }

        /// <summary>
        /// 电子邮箱不能为空！
        /// </summary>
        public static string EmailNotNull
        {
            get
            {
                return GetMessage("EmailEmpty");
            }
        }

        /// <summary>
        /// 用户{0}已存在！
        /// </summary>
        public static string UserExist
        {
            get
            {
                return GetMessage("UserExist");
            }
        }

        /// <summary>
        /// 验证码不能为空！
        /// </summary>
        public static string CodeNotNull
        {
            get { return GetMessage("CodeNotNull"); }
        }
        #endregion

        #region 贴子
        public static string NoThisPost
        {
            get
            {
                return GetMessage("NoThisPost");
            }
        }

        public static string CatalogNotNull
        {
            get { return GetMessage("CatalogNotNull"); }
        }

        public static string TitleNotNull
        {
            get { return GetMessage("TitleNotNull"); }
        }

        public static string ContentNotNull
        {
            get { return GetMessage("ContentNotNull"); }
        }

        public static string NotAllow
        {
            get { return GetMessage("NotAllow"); }
        }

        #endregion

        /// <summary>
        /// 没有权限！
        /// </summary>
        public static string NoPermission
        {
            get { return GetMessage("NoPermission"); }
        }

        /// <summary>
        /// 更新帖子成功！
        /// </summary>
        public static string UpdatePostSuccess
        {
            get { return GetMessage("UpdatePostSuccess"); }
        }

        /// <summary>
        /// 投票标题不允许为空！
        /// </summary>
        public static string VoteTitleNotNull
        {
            get { return GetMessage("VoteTitleNotNull"); }
        }

        /// <summary>
        /// 帖子内容已经屏蔽！
        /// </summary>
        public static string ContentWasHide
        {
            get { return GetMessage("ContentWasHide"); }
        }

        /// <summary>
        /// 两次输入的密码不同!
        /// </summary>
        public static string PasswordNotSame
        {
            get { return GetMessage("PasswordNotSame"); }
        }

        /// <summary>
        /// 投票成功！
        /// </summary>
        public static string VoteSuccess
        {
            get { return GetMessage("VoteSuccess"); }
        }

        /// <summary>
        /// 返回
        /// </summary>
        public static string Return
        {
            get { return GetMessage("Return"); }
        }

        /// <summary>
        /// "超时，请刷新页面！"
        /// </summary>
        public static string TimeOut
        {
            get { return GetMessage("TimeOut"); }
        }

        /// <summary>
        /// 验证码不对！
        /// </summary>
        public static string CodeError
        {
            get { return GetMessage("CodeError"); }
        }

        /// <summary>
        /// 尚未登录！
        /// </summary>
        public static string NotLogin
        {
            get { return GetMessage("NotLogin"); }
        }

        /// <summary>
        /// 不允许反复投票！
        /// </summary>
        public static string NotAllowRevote
        {
            get { return GetMessage("NotAllowRevote"); }
        }

        /// <summary>
        /// 该帖已被锁！
        /// </summary>
        public static string PostLoked
        {
            get { return GetMessage("PostLocked"); }
        }

        public static string DeleteSuccess
        {
            get { return GetMessage("DeleteSuccess"); }
        }

        /// <summary>
        /// 帖子或回复已被加黑！
        /// </summary>
        public static string IsBlack
        {
            get { return GetMessage("IsBlack"); }
        }

        public static string CodeToString(MessageCode code)
        {
            switch (code)
            {
                case MessageCode.CodeError:
                    return "验证码不正确";
                case MessageCode.UserIsActived:
                    return "用户帐号已被激活";
                case MessageCode.EmailRegistered:
                    return "该邮箱已被注册";
                case MessageCode.NameRegistered:
                    return "该用户名已被注册";
                case MessageCode.NoThisUser:
                    return NoThisUser;
                case MessageCode.PasswordError:
                    return PasswordError;
                case MessageCode.NoPermission:
                    return NoPermission;
                case MessageCode.UserNotActive:
                    return "用户帐号尚未被激活";
                case MessageCode.AddPostSuccess:
                    return AddPostSuccess;
                case MessageCode.UpdatePostSuccess:
                    return "更新帖子成功";
                case MessageCode.UpdateReplySuccess:
                    return "更新回复成功";
                case MessageCode.AnswerError:
                    return "答案错误";
                case MessageCode.DeletePostSuccess:
                    return DeleteSuccess;
            }
            string message = GetMessage(code.ToString());
            if (message == null)
                message = code.ToString();
            return message;
        }

    }
}